package com.shunhao.base

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter

/**
 * ListView GridView BaseAdapter
 *
 * @author 康贵阳
 */
open class BaseLvAdapter<T>(
    protected var context: Context, data: MutableList<T>? = null
) : BaseAdapter() {

    var data: MutableList<T> = data ?: arrayListOf()
        internal set

    override fun getCount(): Int {
        return data.size
    }

    override fun getItem(position: Int): T {
        return data[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? {
        return null
    }

    fun setData(data2: MutableList<T>?) {
        if (data2 != null) {
            this.data = data2
        }
    }

}